/**
 * \file CProspectFrm.h
 * \author Corentin Le Bail
 * \date 2009-2012
 * \brief Fichier de déclaration de la class CProspectFrm
 */
//------------------------------------------------------------------------------
#ifndef __CPROSPECTFRM_H__
#define __CPROSPECTFRM_H__
//------------------------------------------------------------------------------
#include "CMyMainWindow.h"
#include <QMenu>
#include <QAction>
#include "CMainFrm.h"
#include "ui_CProspectFrm.h"
#include "CGrilleWidget.h"
#include "CTextWidget.h"
//------------------------------------------------------------------------------
/**
 * \class CProspectFrm CProspectFrm.h "CProspectFrm.h"
 * \brief Classe de la fenêtre des prospects.
 */
class CProspectFrm : public CMyMainWindow, private Ui::ProspectFrm
{
	Q_OBJECT
	public:
		/**
		 * \fn CProspectFrm(QString name, QString lastCode, CMainFrm *parent = 0)
		 * \brief Constructeur
		 * \param[in] name Nom de l'objet
		 * \param[in] lastCode Dernier code traité
		 * \param[in] parent Référence vers un objet parent
		 */
		CProspectFrm(QString name, QString lastCode, CMainFrm *parent = 0);
	private:
		enum {cnaNum, cnaAction, cnaDate, cnaHeure, cnaQui, cnaInterloc, cnaCommentaires} EColActionsNames;
		enum {cncpNum, cncpDefaut, cncpNom, cncpFonction, cncpTel, cncpFax, cncpMail} EColContactProspectNames;
		enum {cndpNum, cndpTitre, cndpDate, cndpPar, cndpMontant, cndpStatus} EColDevisProspectNames;
		enum {cnopNum, cnopDescription, cnopDocument} EColDocumentsProspectName;
		enum {ctnpId, ctnpNom, ctnpTaux, ctnpCompteComptable} EColTvaName;
		enum {etnAction, etnContacts, etnDevis, etnDocs, etnTva, etnCommentaires} ETabName;
		
		CGlobal::EAction actionCur;
		QString derniereRequete;
		QSize sizeFrmRecherche;
		QPoint posFrmRecherche;
		int colSortFrmRecherche;
		Qt::SortOrder sortOrderFrmRecherche;
		int lastLigneFrmRecherche;
		CTextWidget *commentaires;
		CGrilleWidget *actionWidget;
		CGrilleWidget *contactWidget;
		CGrilleWidget *devisWidget;
		CGrilleWidget *documentsWidget;
		CGrilleWidget *tvaWidget;
		QMenu *popupMenu;
		QMenu *favorisMenu;
		QAction *actActionFromContact;
		QAction *actMailFromContact;
		QAction *actNouveauFavoris;
		QAction *actGestFavoris;
		QAction *actSeparator;
		int curContactNum;
		CMainFrm *mainFrm;
	
		void setActionCur(CGlobal::EAction action);
		CGlobal::EAction getActionCur(void); 
		void closeEvent(QCloseEvent * event);
		void resizeEvent(QResizeEvent * event);
		void createGrilleActions(void);
		void loadGrilleActions(void);
		void createGrilleContact(void);
		void loadGrilleContact(void);
		void createGrilleDevis(void);
		void loadGrilleDevis(void);
		void createGrilleDocuments(void);
		void loadGrilleDocuments(void);
		void createGrilleTva(void);
		void loadGrilleTva(void);
		void makeMenu(void);
		void loadFavoris(QMenu *menu, int * parent=0);
		void dropFavoris(QMenu *menu);
		void creerDocument(int row);
		void makeRequete(QString &requete, QString &alias);
		void showFormulaire(QSqlQuery *query, CGlobal::EAction& action);
	private slots:
		void on_actAjouter_triggered(void);
		void on_actValider_triggered(void);
		void on_actAnnuler_triggered(void);
		void on_actSupprimer_triggered(void);
		void onChange(void);
		void on_actRechercheUneFiche_triggered(void);
		void on_actDerniereRecherche_triggered(void);
		void on_actAbonneEMailing_triggered(void);
		void on_actCopieAdresse_triggered(void);
		void ajouteAction(bool &goToLast, int numContact=-1);
		void supprimeAction(int row, bool& ok);
		void on_actDerniereAction_triggered(void);
		void on_actProspectsSansAction_triggered(void);
		void modifiAction(int row, int column);
		void actionDoubleClicked(int row, int column);
		void devisDoubleClicked(int row, int column);
		void onCombo(CMyComboBox *comboBox);
		void onMailTo(QString href);
		void ajouteContact(bool &goToLast);
		void supprimeContact(int row, bool& ok);
		void modifiContact(int row, int column);
		void contactDoubleClicked(int row, int column);
		void tableCustomContextMenuRequested(const QPoint & pos);
		void actActionFromContact_triggered(void);
		void on_actFavoris_triggered(void);
		void actNouveauFavoris_triggered(void);
		void actGestFavoris_triggered(void);
		void actSelectFavoris_triggered(void);
		void actMailFromContact_triggered(void);
		void onInvokeHelp(CChamp *champ);
		void ajouteDocument(bool &goToLast);
		void supprimeDocument(int row, bool& ok);
		void modifiDocument(int row, int column);
		void documentDoubleClicked(int row, int column);
		void beforeInsertAction(const QSqlQuery *query, CMyTableWidgetItem *item);
		void beforeChangeRecordContact(const QSqlQuery *query, int row);
		void on_siteWeb_clickWithCtrl(void);
		void modifiTva(int row, int column);
};
//------------------------------------------------------------------------------
#endif //__CPROSPECTFRM_H__
//------------------------------------------------------------------------------